#include "MBWeightMethodManager.h"
#include <assert.h>


MBWeightMethodManager *MBWeightMethodManager::weightmethodManager= 0;
double MBWeightMethodManager::MB_REAL_TO_PROJECTED_AREA_RATIO_WEIGHT_INFINITY = 25.0;
double MBWeightMethodManager::MB_SQUARED_SINE_VIEW_NORMAL_WEIGHT_INFINITY = 1.0;

/**
  *	Constructs a new MBWeightMethodeManager object
  */
MBWeightMethodManager::MBWeightMethodManager( void )
{
	mCurrentMethod = MB_REAL_TO_PROJECTED_AREA_RATIO;
}

/**
  *	Destroys the MBWeightManager 
  */
MBWeightMethodManager::~MBWeightMethodManager( void )
{

}


/**
  *	Returns the only instance of the MBWeightMethodeManager class
  *
  * @return only instance of the MBWeightMethodeManager class
  */
MBWeightMethodManager &MBWeightMethodManager::Get( void )
{
	if (!weightmethodManager)
		weightmethodManager = new MBWeightMethodManager;

	return *weightmethodManager;
}

MBWeightMethod MBWeightMethodManager::GetCurrentMethod( void ) const
{
	return mCurrentMethod;
}

void MBWeightMethodManager::SetCurrentMethod( MBWeightMethod method )
{
	mCurrentMethod = method;
}

/** get the threshold of the given method */
double MBWeightMethodManager::GetMethodWeightInfinity( MBWeightMethod method ) const
{
	switch(method)
	{
		case( MB_REAL_TO_PROJECTED_AREA_RATIO ):
			return MB_REAL_TO_PROJECTED_AREA_RATIO_WEIGHT_INFINITY;

		case( MB_SQUARED_SINE_VIEW_NORMAL ):
			return MB_SQUARED_SINE_VIEW_NORMAL_WEIGHT_INFINITY;

		default:
			assert(false && "Non-existent MBWeightMethod");
	}
}

/** get the threshold of the current method */
double MBWeightMethodManager::GetCurrentMethodWeightInfinity( void ) const
{
	return GetMethodWeightInfinity( mCurrentMethod );
}


